import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import '@/assets/scss/reset.scss'
import '@/assets/scss/index.scss'
import ElementUI from 'element-ui'
import VueCookies from 'vue-cookies'
import axios from 'axios'
import 'element-ui/lib/theme-chalk/index.css'
import 'element-ui/lib/theme-chalk/display.css';
import '@/assets/icon/iconfont.css'
import '@/assets/icon/iconfont.js'
import echarts from 'echarts'

import elEn from 'element-ui/lib/locale/lang/en' //Element-UI国际化所需
import elZh from 'element-ui/lib/locale/lang/zh-CN' //Element-UI国际化所需
// import elZhTw from 'element-ui/lib/locale/lang/zh-TW' //Element-UI国际化所需
import elJa from 'element-ui/lib/locale/lang/ja' //Element-UI国际化所需
import en from '@/assets/language/en'
import ja from '@/assets/language/ja'
import zh from '@/assets/language/zh'
import moment from 'moment-timezone';

import { parseTime,formatStr,checkPermission} from "@/utils/common.js"

import './permission'
import VueI18n from 'vue-i18n'

Vue.use(VueI18n)
//多语言实例
const i18n = new VueI18n({
  locale:(function(){
    if(localStorage.getItem('locale')){
      return localStorage.getItem('locale')
    }
    return 'zh'
  }()),
  messages:{
    'en':{...en,...elEn},// //require('./assets/language/en'), 英文语言包
    'zh':{...zh,...elZh},         //require('./assets/language/zh_HANS'), //简体中文
    'ja': {...ja,...elJa} //   require('./assets/language/ja'), //日文
  }
})


Vue.use(VueCookies)
// Vue.use(ElementUI)
Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
})
Vue.prototype.$axios = axios
Vue.prototype.$echarts = echarts

Vue.prototype.$getLocalTime = function(datetime) {
	var d = moment.tz(datetime, "Asia/Shanghai"); //mark current time as china time
	var localtz = moment.tz.guess() //get local time
	var date = d.clone().tz(localtz); //convert to local time
	return moment(date).format("YYYY-MM-DD HH:mm:ss");
}

Vue.config.productionTip = false
Vue.prototype.parseTime = parseTime
Vue.prototype.formatStr = formatStr
Vue.prototype.checkPermission = checkPermission

new Vue({
  router,
  i18n,
  store,
  render: h => h(App),
}).$mount('#app')
